package net.anzhuo.common.utils;

import java.util.Hashtable;
import java.util.List;

import net.anzhuo.entity.GsBase;

public class CalcUtils {
	
public Hashtable<String,Integer> enterpriseStatus=new Hashtable<String,Integer>();
	
 
public Hashtable<String,Integer> regTime=new Hashtable<String,Integer>();
 
public Hashtable<String,Integer> province=new Hashtable<String,Integer>();
 
public Hashtable<String,Integer> city=new Hashtable<String,Integer>();
 
public Hashtable<String,Integer> area=new Hashtable<String,Integer>();
 
public Hashtable<String,Integer> industry=new Hashtable<String,Integer>();
 
public Hashtable<String, Integer> getEnterpriseStatus() {
	return enterpriseStatus;
}

public void setEnterpriseStatus(Hashtable<String, Integer> enterpriseStatus) {
	this.enterpriseStatus = enterpriseStatus;
}

public Hashtable<String, Integer> getRegTime() {
	return regTime;
}

public void setRegTime(Hashtable<String, Integer> regTime) {
	this.regTime = regTime;
}

public Hashtable<String, Integer> getProvince() {
	return province;
}

public void setProvince(Hashtable<String, Integer> province) {
	this.province = province;
}

public Hashtable<String, Integer> getCity() {
	return city;
}

public void setCity(Hashtable<String, Integer> city) {
	this.city = city;
}

public Hashtable<String, Integer> getArea() {
	return area;
}

public void setArea(Hashtable<String, Integer> area) {
	this.area = area;
}

public Hashtable<String, Integer> getIndustry() {
	return industry;
}

public void setIndustry(Hashtable<String, Integer> industry) {
	this.industry = industry;
}

public void calc(List<GsBase> base)
{
	enterpriseStatus.clear();
	regTime.clear();
	province.clear();
	city.clear();
	area.clear();
	industry.clear();
	for(GsBase g:base)
	{
		if(g.getEnterpriseStatus()!=null&&!g.getEnterpriseStatus().equals("")) {
		if(enterpriseStatus.containsKey(g.getEnterpriseStatus()))
		{
			int count=enterpriseStatus.get(g.getEnterpriseStatus());
			count++;
			enterpriseStatus.put(g.getEnterpriseStatus(), count);
		}else
		{
			enterpriseStatus.put(g.getEnterpriseStatus(), 1);
		}
		}
		//regTime
		if(g.getRegTime()!=null&&!g.getRegTime().equals(""))
		{
			int year=0;
			try {
			 year=Integer.parseInt(g.getRegTime().substring(0, 4));
			}catch(Exception e)
			{
				year=0;
			}
			if(year>1900)
			{	if(regTime.containsKey(year+""))
				{
					int count=regTime.get(year+"");
					count++;
					regTime.put(year+"", count);
				}else
				{
					regTime.put(year+"", 1);
				}
			}
		}
		//province
		if(g.getProvince()!=null&&!g.getProvince().equals("")) {
		if(province.containsKey(g.getProvince()))
		{
			int count=province.get(g.getProvince());
			count++;
			province.put(g.getProvince(), count);
		}else
		{
			province.put(g.getProvince(), 1);
		}}
		//city
		if(g.getCity()!=null&&!g.getCity().equals("")) {
		if(city.containsKey(g.getCity()))
		{
			int count=city.get(g.getCity());
			count++;
			city.put(g.getCity(), count);
		}else
		{
			city.put(g.getCity(), 1);
		}}
		//area
		if(g.getArea()!=null&&!g.getArea().equals("")) {
		if(area.containsKey(g.getArea()))
		{
			int count=area.get(g.getArea());
			count++;
			area.put(g.getArea(), count);
		}else
		{
			area.put(g.getArea(), 1);
		}}
		
		//industry
		if(g.getIndustry()!=null&&!g.getIndustry().equals(""))
		{
		if(industry.containsKey(g.getIndustry()))
		{
			int count=industry.get(g.getIndustry());
			count++;
			
			industry.put(g.getIndustry(), count);
		}else
		{
			industry.put(g.getIndustry(), 1);
		}}
	}
}
}
